package redis

import (
	"fmt"
	"github.com/go-redis/redis"
	"zg4week2/appconfig"
)

var (
	err    error
	Client *redis.Client
)

func RedisApp() {
	stu := appconfig.AppCon.RedisApp
	res := fmt.Sprintf("%s:%d", stu.Addr, stu.Pass)
	Client = redis.NewClient(&redis.Options{
		Addr:     res,
		Password: "", // no password set
		DB:       0,  // use default DB
	})

	_, err = Client.Ping().Result()
	if err != nil {
		fmt.Println("redis 连接失败", err)
		return
	}
	fmt.Println("redis 连接成功")

	// Output: PONG <nil>
}
